package com.zhiwei.codesecurity.common.webservice.checkmarx.wsdk.args;

import java.util.regex.Matcher;

public class SvnArgs extends BaseArgs {
    private String svnUsr;
    private String svnPwd;
    private String svnUrl;
    private String svnPath;
    private int svnPort;
    public String getSvnUsr() {
        return svnUsr;
    }
    public void setSvnUsr(String svnUsr) {
        this.svnUsr = svnUsr;
    }
    public String getSvnPwd() {
        return svnPwd;
    }
    public void setSvnPwd(String svnPwd) {
        this.svnPwd = svnPwd;
    }
    public String getSvnUrl() {
        return svnUrl;
    }
    public void setSvnUrl(String svnUrl) {
        String url = svnUrl;
        Matcher m = REX_URL.matcher(url);
        while (m.find()) {
            String domain = m.group();
            String[] urs = domain.split(":");
            if (urs.length == 3 && !"".equals(urs[2].trim())) {
                int port = Integer.parseInt(urs[2].trim());
                url = url.substring(domain.length());
                domain = domain.substring(0, domain.lastIndexOf(':'));
                url = domain + "/" + url;
                setSvnPort(port);
                break;
            }
        }
        this.svnUrl = url;
    }
    public String getSvnPath() {
        return svnPath;
    }
    public void setSvnPath(String svnPath) {
        this.svnPath = svnPath;
    }
    public int getSvnPort() {
        return svnPort;
    }
    public void setSvnPort(int svnPort) {
        this.svnPort = svnPort;
    }
}
